import type { Search } from '~/constants/types';
import { http } from '~/utils/request';

// 收藏店铺
export function collectStore(type: string, id: string) {
  return http.request({
    url: `/member/collection/add/${type}/${id}`,
    method: "POST",
    data: { type, id },
  });
}

// 取消 收藏店铺
export function cancelStoreCollect(type: string, id: string) {
  return http.request({
    url: `/member/collection/delete/${type}/${id}`,
    method: "DELETE",
    data: { type, id },
  });
}

// 查看是否收藏店铺
export function isStoreCollection(type: string, goodsId: string) {
  return http.request({
    url: `/member/collection/isCollection/${type}/${goodsId}`,
    method: "GET",
  });
}


/**
 * 收藏
 * @returns {AxiosPromise}
 */
export function favoriteSomething(type: string, id: string, methods: 'add' | 'isCollection' | 'delete') {
  const coffer: any = {
    'isCollection': "GET",
    'add': "POST",
    'delete': "DELETE"
  }
  return http.request({
    url: `/member/collection/${methods}/${type}/${id}`,
    method: coffer[methods],
  });
}

/**
 * 分页获取订单
 * @param params
 */
export function getOrderList(params: Search) {
  return http.request({
    url: "/order/order",
    method: "GET",
    params,
  });
}

/**
 * 分页获取预存款充值记录
 * @param params
 */
export function getWalletLog(params: Search) {
  return http.request({
    url: "/wallet/log",
    method: "GET",
    params,
  });
}

/**
 * 分页获取提现记录
 * @param params
 */
export function withdrawalRecord(params: Search) {
  return http.request({
    url: "/wallet/wallet/withdrawalRecord",
    method: "GET",
    params,
  });
}

/**
 * 获取当前会员优惠券列表
 * @param params
 * @returns {AxiosPromise}
 */
export function getMemberCoupons(data: Search) {
  return http.request({
    url: `/promotion/coupon/getCoupons`,
    method: "GET",
    params: data,
  });
}

/**
 * 获取商品收藏
 * @param params
 * @returns {AxiosPromise}
 */
export function getMemberCollection(params: Search, type: string) {
  return http.request({
    url: `/member/collection/${type}`,
    method: "GET",
    params,
  });
}

/**
 * 获取会员积分VO
 * @param
 */
export function getMemberPoints() {
  return http.request({
    url: `member/memberPointsHistory/getMemberPointsHistoryVO`,
    method: "GET",
  });
}

/**
 * 获取积分明细数据
 * @param params
 * @returns {AxiosPromise}
 */
export function getPoints(params: Search) {
  return http.request({
    url: "member/memberPointsHistory/getByPage",
    method: "GET",
    params,
  });
}


/**
 * 足迹
 */
export function getTracks(params: Search) {
  return http.request({
    url: "/member/footprint",
    method: "GET",
    params,
  });
}

/**
 * 根据id删除会员足迹
 * @param id
 */
export function deleteTracks(ids: any) {
  return http.request({
    url: `/member/footprint/delByIds/${ids}`,
    method: "DELETE",
  });
}



/**
 * 意见反馈
 */
export function feedback(params: any) {
  return http.request({
    url: "/other/feedback",
    method: "POST",
    params,
  });
}


/**
 * 通过短信重置密码
 * @param  mobile
 */
export function resetByMobile(params: any) {
  return http.request({
    url: `/passport/member/resetByMobile`,
    method: "POST",
    params,
  });
}

/**
 * 通过短信重置密码
 * @param  mobile
 */
export function resetByMobileWithVerificationEnums(verificationEnums: string, params: any) {
  return http.request({
    url: `/passport/member/resetByMobile/${verificationEnums}`,
    method: "POST",
    params,
  });
}

/**
 * 修改密码
 * @param  newPassword
 * @param  password
 */

export function modifyPass(params: any) {
  return http.request({
    url: `/passport/member/modifyPass`,
    method: "PUT",
    params,
  });
}

/**
 * 申请分销商
 */
export function applyDistribution(params: any) {
  return http.request({
    url: `/distribution`,
    method: "POST",
    params,
  });
}

/**
 * 投诉列表
 */
export function getComplainList(params: any) {
  return http.request({
    url: `/order/complain`,
    method: "GET",
    params,
  });
}

/**
 * 获取当前用户的预存款
 * @returns {AxiosPromise}
 */
export function getUserWallet() {
  return http.request({
    url: "/wallet/wallet",
    method: "GET",
  });
}

// 提现(新接口)
export function withdrawalApply(params: any) {
  return http.request({
    url: "/wallet/wallet/newWithdrawal",
    method: "POST",
    data: params,
  });
}


/**
 * 获取当前会员的浏览数量是多少
 * @param params
 * @returns {AxiosPromise}
 */
export function getFootprintNum() {
  return http.request({
    url: "/member/footprint/getFootprintNum",
    method: "GET",
  });
}

/**
 * 获取当前会员可使用的优惠券数量
 *
 */
export function getCouponsNum() {
  return http.request({
    url: `/promotion/coupon/getCouponsNum`,
    method: "GET",
  });
}


// 在线充值
export function recharge(params: any) {
  return http.request({
    url: "/trade/recharge",
    method: "POST",
    params,
  });
}

/**
 * 订单评论
 * @param params
 */
export function commentsMemberOrder(params: any) {
  return http.request({
    url: "/member/evaluation",
    method: "POST",
    header: { "content-type": "application/x-www-form-urlencoded" },
    data: params,
  });
}

export function getCurrentPhone() {
  return http.request({
    url: '/auth/getObfuscatePhoneNumber',
    method: 'GET'
  })
}

// 绑定手机号
export function bindMobile(params: any) {
  return http.request({
    url: '/auth/bind/mobile',
    method: 'POST',
    params
  })
}
